<% import org.codehaus.groovy.grails.orm.hibernate.support.ClosureEventTriggeringInterceptor as Events %>
<%=packageName%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="main" />
        <script type="text/javascript" src ="\${resource(dir:'js',file:'function.js')}">
        </script>
        <title>查询${className}</title>
    </head>
    <body>
        <div class="body">
            <h1>查询${className}</h1>
			<g:if test="\${flash.message}">
			<div class="message">\${flash.message}</div>
			</g:if>
            <g:form action="search" method="post">
                <div class="dialog">
                    <table>
                        <tr class="prop">
                            <td class="name" valign="middle">
                                <label for="name">Field1</label>
                            </td>
                            <td class="value">
                                <input type="text" maxlength="20" name="name"  value="\${params.name}" />
                            </td>
                            <td class="name" valign="middle">
                                <label for="loginName">Field2</label>
                            </td>
                            <td class="value">
                                <input type="text" maxlength="20" name="name2" value="\${params.name2}" />
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="buttons" align="center">
                    <input type="submit" value="查询" class="formbutton" />
                    <input type="reset" value="重置" class="formbutton" />
                </div>
                <div class="buttons" align="left">
                    <span onClick="request(this, 'create.gsp')">
                    	<input type="button" value="新建" class="formbutton" /></span>
                    <span onClick="request(this, 'edit.gsp')">
                    	<input type="button" value="修改" class="formbutton" /></span>
                    <span onClick="request(this, 'list.gsp')">
                    	<input type="button" value="列表" class="formbutton" /></span>
                    <span onClick="request(this, 'show.gsp')">
                    	<input type="button" value="详细" class="formbutton" /></span>
                </div>
            </g:form>
			
			<g:if test="\${${propertyName}List}"
            <div class="list">
                <table>
                    <thead>
                        <tr>
							<th class="sortable">序号</th>
                        <%
                            excludedProps = ['version',
                                               Events.ONLOAD_EVENT,
                                               Events.BEFORE_DELETE_EVENT,
                                               Events.BEFORE_INSERT_EVENT,
                                               Events.BEFORE_UPDATE_EVENT]
                            
                            props = domainClass.properties.findAll { !excludedProps.contains(it.name) && it.type != Set.class }
                            Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
                            props.eachWithIndex { p,i ->
                   	            if(i < 6) {
                   	                if(p.isAssociation()) { %>
								<th>${p.naturalName}</th>
                   	    <%          } else { %>
								<g:sortableColumn property="${p.name}" title="${p.naturalName}"  params="\${params}"/>
                        <%  }   }   } %>
                        </tr>
                    </thead>
                    <tbody>
                    <g:each in="\${${propertyName}List}" status="i" var="${propertyName}">
                        <tr class="\${(i % 2) == 0 ? 'odd' : 'even'}">
							<td>\${i + params.offset.toInteger() + 1}</td>
                        <%  props.eachWithIndex { p,i ->
                                if(i == 0) { %>
                            <td><g:link action="edit" id="\${${propertyName}.id}">\${fieldValue(bean:${propertyName}, field:'${p.name}')}</g:link></td>
                        <%      } else if(i < 6) { %>
                            <td>\${fieldValue(bean:${propertyName}, field:'${p.name}')}</td>
                        <%  }   } %>
                        </tr>
                    </g:each>
                    </tbody>
                </table>
            </div>
            <div class="paginateButtons">
                <g:paginate total="\${${propertyName}Total}" params="\${params}" />
            </div>
			</g:if>
			
        </div>
    </body>
</html>
